<?xml version="1.0" encoding="UTF-8"?>
<%@ page contentType="application/x-blueprint+xml;charset=UTF-8" language="java" %>
<%@ page import="com.vhly.bpplat.twitter.HTTPClient" %>


<page xmlns:xsd="http://mobile.yahoo.com/widgets/schema/1.5/blueprint/">
    <content>
        <module>
            <header layout="simple">
                <layout-items>
                    <block class="title">Search Friends</block>
                </layout-items>
            </header>
            <%
                Object login = session.getAttribute("login");
                if (login != null) {
                    String type = request.getParameter("t");
                    String uid = request.getParameter("u");
                    String user = (String) session.getAttribute("user");
                    String pass = (String) session.getAttribute("pass");
                    String acc = user + ":" + pass;
                    String target = null;
                    if (type.equals("f")) {
                        target = "http://twitter.com/friendships/create/" + uid + ".xml";
                    } else if (type.equals("u")) {
                        target = "http://twitter.com/friendships/destroy/" + uid + ".xml";
                    }
                    String xml = null;
                    if (target != null) {
                        xml = HTTPClient.request(target, acc, null, true);
                    }
                    if (xml != null) {
            %>
            <block><%=type.equals("f") ? "Follow" : "UnFollow"%> Success!</block>
            <%
            } else {
            %>
            <block><%=type.equals("f") ? "Follow" : "UnFollow"%> Faild!</block>
            <%
                }
            } else {
            %>
            <block>Need Login</block>
            <%
                }
            %>
        </module>
    </content>
</page>